From: Ruben Bridgewater Date: Mon, 30 Jun 2025 11:51:40 +0000 (+0200) Subject: [PATCH] v8: fix missing callback in heap utils destroy X-Git-Tag: archive/raspbian/20.19.2+dfsg-1+rpi1+deb13u1^2~11 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/%22stanciumarius94%40gmail.com//%22mailto:i18n-csb%40linuxcsb.org/%22/%22http:/www.example.com/%22stanciumarius94%40gmail.com/%22mailto:i18n-csb%40linuxcsb.org/%22?a=commitdiff_plain;h=9d6aaf3017d58913a8dee95a5fa3ae626dec7d38;p=nodejs.git [PATCH] v8: fix missing callback in heap utils destroy This fixes the v8.getHeapSnapshot() calls not properly being destroyed. Pipeline calls would for example not properly end without the callback being in place. PR-URL: https://github.com/nodejs/node/pull/58846 Reviewed-By: Ethan Arrowood Reviewed-By: Luigi Pinca Reviewed-By: Chengzhong Wu Reviewed-By: Shelley Vohr Gbp-Pq: Topic sec Gbp-Pq: Name 19-v8-fix-missing-callback-in-heap-utils-destroy.patch --- diff --git a/lib/internal/heap_utils.js b/lib/internal/heap_utils.js index c39d811ab..6d72fb1d6 100644 --- a/lib/internal/heap_utils.js +++ b/lib/internal/heap_utils.js @@ -53,11 +53,12 @@ class HeapSnapshotStream extends Readable { this[kHandle].readStart(); } - _destroy() { + _destroy(err, callback) { // Release the references on the handle so that // it can be garbage collected. this[kHandle][owner_symbol] = undefined; this[kHandle] = undefined; + callback(err); } [kUpdateTimer]() { diff --git a/test/sequential/test-heapdump.js b/test/sequential/test-heapdump.js index 1388623e6..ee025f57f 100644 --- a/test/sequential/test-heapdump.js +++ b/test/sequential/test-heapdump.js @@ -8,6 +8,7 @@ if (!common.isMainThread) const { writeHeapSnapshot, getHeapSnapshot } = require('v8'); const assert = require('assert'); const fs = require('fs'); +const { promises: { pipeline }, PassThrough } = require('stream'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); @@ -76,3 +77,13 @@ process.chdir(tmpdir.path); JSON.parse(data); })); } + +{ + const passthrough = new PassThrough(); + passthrough.on('data', common.mustCallAtLeast(1)); + + pipeline( + getHeapSnapshot(), + passthrough, + ).then(common.mustCall()); +}